package db4o;

import com.db4o.ObjectContainer;
import com.db4o.cs.Db4oClientServer;

import db4oServer.ServerSetup;
import db4oServer.StartServer;

public abstract class DBManager implements ServerSetup{
	/*
	 * Singleton class
	 */
	private StartServer server = new StartServer();
	
//	private final static String DB4OFILENAME = "db4os.yep";

	private static volatile ObjectContainer dbManager = null;

	public ObjectContainer getDbManager() {
		  		
		if (dbManager==null) {
			
			synchronized (DBManager.class) {
//				server.runServer();
				dbManager = Db4oClientServer.openClient(Db4oClientServer
				            .newClientConfiguration(), HOST, PORT, USER, PASS);				
			}
		}
		return dbManager;
	}

	public void closeDb() {
		server.close();
//		dbManager.close();
	}

}
